
var http = require('http');
var zlib = require('zlib');

http.createServer(function(req, resp){
    var i = 1024;
    var data = '';

    while(i--) {
        data += '.';
    }

    var flagGzip = (req.headers['accept-encoding'] || '').indexOf('gzip') !== -1;
    if (flagGzip) {
        zlib.gzip(data, function(err, data){
            resp.writeHead(200, {
                'Content-Type': 'text/plain',
                'Content-Encoding': 'gzip'
            });
            resp.end(data);
        });
    } else {
        resp.writeHead(200, {
            'Content-Type': 'text/plain'
        });
        resp.end(data);
    }
}).listen(8080);



